﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;



namespace BillingSystem
{
    /// <summary> Импорт/Экспорт XML </summary>
    class XMLBoss
    {
        private const string default_file_path = "standart.xml";

        public XMLBoss()
        { }        
        
        /// <summary> Запись xml </summary>
        public bool WriteXml(DataTable dataTable, string path)
        {
            try
            {
                dataTable.WriteXml(path);
                return true;
            }
            catch (ArgumentNullException exc) { return false; }
        }

        /// <summary> Запись xml по умолчанию </summary>
        public bool WriteXml(DataTable dataTable)
        {
            try
            {
                dataTable.WriteXml(default_file_path);
                return true;
            }
            catch (NullReferenceException exc) { return false; }
        }

        /// <summary> Чтения xml из path </summary>
        public void ReadXml(DataTable dataTable, string path)
        {
            dataTable.ReadXml(path);
        }

        /// <summary> Чтение xml по умолчанию </summary>
        public void ReadXml(DataTable dataTable)
        {
            dataTable.ReadXml(default_file_path);
        }
    }
}
